//This is Multiplication of two Matrix

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
	int m1[10][10], m2[10][10], m3[10][10], i, j, r1, r2, c1, c2, sum, k;
	clrscr();

	//Putting Order of 1st Matrix
	printf("\n\n\t\tPlease Enter the 1st Matrix's Order: ");
	scanf("%d%d", &r1, &c1);

	//Putting Order of 2nd Matrix
	printf("\n\n\t\tPlease Enter the 1st Matrix's Order: ");
	scanf("%d%d", &r2, &c2);

	if(r2 == c1)
	{
		printf("\n\n\t\tPlease Enter the 1st Matrix: ");

		for(i = 0; i < r1; i++)
		{
			for(j = 0; j < c1; j++)
			{
				scanf("%d", &m1[i][j]);
			}
		}

		printf("\n\n\t\tPlease Enter the 2nd Matrix: ");

		for(i = 0; i < r2; i++)
		{
			for(j = 0; j < c2; j++)
			{
				scanf("%d", &m2[i][j]);
			}
		}
		//Printing 1st Matrix
		printf("\n\n\tThe 1st Matrix is:\n\n");
		for(i = 0; i < r1; i++)
		{
			for(j = 0; j < c1; j++)
			{
				printf("\t%d", m1[i][j]);
			}
			printf("\n");
		}

		//printing 2nd Matrix
		printf("\n\n\tThe 2nd Matrix is:\n\n");

		for(i = 0; i < r2; i++)
		{
			for(j = 0; j < c2; j++)
			{
				printf("\t%d", m2[i][j]);
			}
			printf("\n");
		}

		//Multiplication of Two Matrix
		for(i = 0; i < r1; i++)
		{
			for(j = 0; j < c2; j++)
			{
				sum = 0;

				for(k = 0; k < r1; k++)
				{
					sum = sum + m1[i][k] * m2[k][j];

					m3[i][j] = sum;
				}
			}
		}
		//Printing Added of  Two Matrix.
		printf("\n\n\tThe Multiplication of two Matrix is:\n\n");

		for(i = 0; i < r1; i++)
		{
			for(j = 0; j < c2; j++)
			{
				printf("\t%d", m3[i][j]);
			}
			printf("\n");
		}
	}
	else
	{
		printf("\n\n\t\tMultiplication Cannot be done.");
	}

	getch();

}